package com.woniuxy01;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-07-16 14:26
 */
public class Test09 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //产生一个随机数
        int random ;
        int num, count;
        System.out.println("是否开始游戏y/n");
        String answer = sc.next();
        while (answer.equals("y")) {
            count = 0;
            random = (int) (Math.random() * 100);
            System.out.println("random:" + random);
            do {
                count++;
                System.out.println("输入你猜的数字");
                num = sc.nextInt();
                if (num > random) {
                    System.out.println("猜大了");
                } else if (num < random) {
                    System.out.println("猜小了");
                } else {
                    System.out.println("猜对了");
                    break;
                }
            } while (count < 3);
            System.out.println("是否继续y/n");
            answer = sc.next();
        }

        System.out.println("游戏结束");
    }
}
